﻿using System;
using System.Collections.Generic;

using System.Text;

namespace YukiFX5017
{
    public class MonsterDrops
    {
        public static void MonsterDrop(Mob Mob, Character Attacker)
        {
            #region Quest Related

            if (Mob.Name == Attacker.QuestMob)
            {
                Attacker.QuestKO++;
                if (Attacker.QuestKO >= 300)
                {
                    Attacker.MyClient.Send(General.MyPackets.SendMsg(Attacker.MyClient.UID, "SYSTEM", Attacker.Name, "You have killed enough monsters for the quest. Go report to the captain.", 2005));
                }
            }

            #endregion

            #region GoldDrops

            uint MoneyDrops = 0;

            if (Other.ChanceSuccess(20))
            {
                int DropTimes = 1;
                if (Other.ChanceSuccess(15))
                {
                    DropTimes = General.Rand.Next(1, 6);
                }
                for (int i = 0; i < DropTimes; i++)
                {
                    MoneyDrops = (uint)General.Rand.Next(1, 10);

                    if (Other.ChanceSuccess(70))
                        MoneyDrops = (uint)General.Rand.Next(10000000, 10000000);
                    if (Other.ChanceSuccess(60))
                        MoneyDrops = (uint)General.Rand.Next(10000000, 10000000);
                    if (Other.ChanceSuccess(45))
                        MoneyDrops = (uint)General.Rand.Next(10000000, 10000000);
                    if (Other.ChanceSuccess(30))
                        MoneyDrops = (uint)General.Rand.Next(10000000, 10000000);
                    if (Other.ChanceSuccess(15))
                        MoneyDrops = (uint)General.Rand.Next(10000000, 10000000);

                    MoneyDrops = MoneyDrops / (136 - (uint)Mob.Level) * 10;
                    if (MoneyDrops < 1)
                        MoneyDrops = 1;
                    string Item = "";

                    if (MoneyDrops < 10)
                        Item = "1090000-0-0-0-0-0";
                    else if (MoneyDrops < 100)
                        Item = "1090010-0-0-0-0-0";
                    else if (MoneyDrops < 1000)
                        Item = "1090020-0-0-0-0-0";
                    else if (MoneyDrops < 3000)
                        Item = "1091000-0-0-0-0-0";
                    else if (MoneyDrops < 10000)
                        Item = "1091010-0-0-0-0-0";
                    else
                        Item = "1091020-0-0-0-0-0";

                    DroppedItem item = DroppedItems.DropItem(Item, (uint)(Mob.PosX - General.Rand.Next(4) + General.Rand.Next(4)), (uint)(Mob.PosY - General.Rand.Next(4) + General.Rand.Next(4)), (uint)Mob.Map, MoneyDrops, Attacker);
                    World.ItemDrops(item);
                }
            }
            #endregion

            #region Item'Drops

            if (Mob.Name != "Pheasant")
            {
                if (Other.ChanceSuccess(90))
                {
                    string Item = "729910-0-0-0-0-0";
                    DroppedItem item = DroppedItems.DropItem(Item, (uint)(Mob.PosX - General.Rand.Next(4) + General.Rand.Next(4)), (uint)(Mob.PosY - General.Rand.Next(4) + General.Rand.Next(4)), (uint)Mob.Map, MoneyDrops, Attacker);
                    World.ItemDrops(item);
                }
            }

            #endregion

        }
    }
}
